package com.dmzc.stage2.chapter14;

/***
 * 懒汉式加同步方法
 * 能够实现懒加载,线程安全，但是效率低下
 */
public final class Singleton2 {
    private byte[] data=new byte[1024];
    private static Singleton2 instance=null;
    private Singleton2(){}
    public static synchronized Singleton2 getInstance(){
        if (null==instance)
            instance=new Singleton2();
        return instance;
    }
}
